package com.doubleutils.utils;

/**
 * 
 * @Description:解决科学计数法的显示问题
 *
 * @author <a href="mailto:zlg156424990@qq.com">赵立刚</a>
 *         <font color=red>不能处理大于1的double,有待完善</font>
 * @time:2017年5月19日 下午2:53:02
 */
public class DoubleToNomalNumber {
	public static String doubleToString(double d) {
		String strDouble = d + "";
		String reuturnStr = "";
		StringBuffer sb = new StringBuffer();
		if (strDouble.contains("E") || strDouble.contains("e")) {
			String[] split = strDouble.split("E");
			if (split.length == 1) {
				split = strDouble.split("e");
			}

			int parseInt = Integer.parseInt(split[1]);
			int abs = Math.abs(parseInt);
			while (abs > 0) {
				sb.append("0");
				abs--;
			}

			String[] split2 = split[0].split("\\.");
			System.out.println(split2);
			boolean flag = true;
			if (split2[1].replaceAll("0", "").length() == 0) {
				flag = false;
			}
			reuturnStr = split2[0];
			if (flag) {
				reuturnStr += split2[1];
			}

			if (parseInt < 0) {
				reuturnStr = sb.toString() + reuturnStr;
				return reuturnStr.substring(0, 1) + "." + reuturnStr.substring(1, reuturnStr.length());
			} else {
				// TODO
				/**
				 * 处理大于1的double
				 */

				return "处理大于1的double,有待完善";

			}

		}
		return strDouble;

	}

	public static void main(String[] args) {
		System.out.println(doubleToString(0.000000078102345810003));
	}
}
